var regWord = /^([\w\/.?&=]+)$/;
var regInt = /^([1-9]{1}\d{0,})$/;
var regFloat = /^(\d+)(\.?)(\d{0,4})$/;

/**
 * 产品名称输入框获取焦点，设置输入框校验显示信息列的样式
 */
function productNameFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "产品名称，必填，最长64个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 产品类型名输入框失去焦点时的校验
 */
function productNameBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "产品名称不能为空";
    } else if(objValue.length > 64 ) {
        errMsg = "产品名称最大长度为64个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 发行银行输入框获取焦点，设置输入框校验显示信息列的样式
 */
function bankFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "发行银行，必填，最长16个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 发行银行输入框失去焦点时的校验
 */
function bankBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "发行银行不能为空";
    } else if(objValue.length > 16 ) {
        errMsg = "发行银行最大长度为16个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 币种输入框获取焦点，设置输入框校验显示信息列的样式
 */
function currencyFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "币种，必填，最长8个字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 币种输入框失去焦点时的校验
 */
function currencyBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "币种不能为空";
    } else if(objValue.length > 8 ) {
        errMsg = "币种最大长度为8个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 委托管理期输入框获取焦点，设置输入框校验显示信息列的样式
 */
function timeLimitFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "委托管理期，必填，正整数，单位为天";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 委托管理期输入框失去焦点时的校验
 */
function timeLimitBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "委托管理期不能为空";
    } else if(!regInt.test(objValue)) {
    	errMsg = "委托管理期必须为正整数";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 付息周期输入框获取焦点，设置输入框校验显示信息列的样式
 */
function paymentCycleFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "付息周期，必填，正整数，单位为天";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 付息周期输入框失去焦点时的校验
 */
function paymentCycleBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "付息周期不能为空";
    } else if(!regInt.test(objValue)) {
    	errMsg = "付息周期必须为正整数";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 预期最高年化收益率 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function expectedProfitFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "必填，小数(最多精确到小数点后4位)";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 预期最高年化收益率输入框失去焦点时的校验
 */
function expectedProfitBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "预期最高年化收益率不能为空";
    } else if(!regFloat.test(objValue)) {
    	errMsg = "预期最高年化收益率必须为数字(最多小数点后4位)";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 产品类型 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function productTypeFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "产品类型, 必填，最大长度8字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 产品类型 输入框失去焦点时的校验
 */
function productTypeBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "产品类型不能为空";
    } else if(objValue.length > 8) {
    	errMsg = "产品类型最大长度为8个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 委托起始金额 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function startAmountFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "必填，小数(最多精确到小数点后4位)";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 委托起始金额 输入框失去焦点时的校验
 */
function startAmountBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "委托起始金额不能为空";
    } else if(!regFloat.test(objValue)) {
    	errMsg = "委托起始金额必须为数字(最多小数点后4位)";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 收益类型 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function earningsTypeFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "收益类型, 必填，最大长度16字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 收益类型 输入框失去焦点时的校验
 */
function earningsTypeBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "收益类型不能为空";
    } else if(objValue.length > 16) {
    	errMsg = "收益类型最大长度为16个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 发售地区 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function placeAreaFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "发售地区, 必填，最大长度8字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 发售地区 输入框失去焦点时的校验
 */
function placeAreaBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "发售地区不能为空";
    } else if(objValue.length > 8) {
    	errMsg = "发售地区最大长度为8个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 递增单位 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function incrementByFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "递增单位，必填，正整数，单位为元";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 递增单位 输入框失去焦点时的校验
 */
function incrementByBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "递增单位不能为空";
    } else if(!regInt.test(objValue)) {
    	errMsg = "递增单位必须为正整数";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 产品管理费 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function feesFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "产品管理费，必填，正整数，单位为元";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 产品管理费 输入框失去焦点时的校验
 */
function feesBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue == "") {
        errMsg = "产品管理费不能为空";
    } else if(!regInt.test(objValue)) {
    	errMsg = "产品管理费必须为正整数";
    }
    if(objValue == "0") {
    	errMsg = "";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 提前终止条件 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function earlyTermCondFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "提前终止条件,最大长度256字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 提前终止条件 输入框失去焦点时的校验
 */
function earlyTermCondBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue != "" && objValue.length > 256) {
    	errMsg = "提前终止条件最大长度为256个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 产品说明 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function productDescFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "产品说明，最大长度1000字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 产品说明 输入框失去焦点时的校验
 */
function productDescBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue != "" && objValue.length > 1000) {
    	errMsg = "产品说明最大长度为1000个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 收益率说明 输入框获取焦点，设置输入框校验显示信息列的样式
 */
function eariningsDescFocus(td_id_Col, s_id_Desc) {
    var infoMsg = "收益率说明，最大长度1000字符";
    focusChk(td_id_Col, s_id_Desc, infoMsg);
}
/**
 * 收益率说明 输入框失去焦点时的校验
 */
function eariningsDescBlur(i_obj, td_id_Col, s_id_Desc) {
	var objValue = i_obj.value;
    if(objValue) {
    	objValue = objValue.trim();
    	i_obj.value = objValue;
    }
    
	var errMsg = "";
    if(objValue != "" && objValue.length > 1000) {
    	errMsg = "收益率说明最大长度为1000个字符";
    }
    
    return blurChk(td_id_Col, s_id_Desc, errMsg);
}

/**
 * 表单提交
 */
function addBankProductFun() {
	// 校验产品名称
	var productNameObj = document.getElementById("productName");
	if(!productNameBlur(productNameObj, 'productNameCol', 'productNameDesc')) {
		return false;
	}
	
	// 校验发行银行
	var bankObj = document.getElementById("bank");
	if(!bankBlur(bankObj, 'bankCol', 'bankDesc')) {
		return false;
	}
	
	// 校验币种
	var currencyObj = document.getElementById("currency");
	if(!currencyBlur(currencyObj, 'currencyCol', 'currencyDesc')) {
		return false;
	}
	
	// 委托管理期
	var timeLimitObj = document.getElementById("timeLimit");
	if(!timeLimitBlur(timeLimitObj, 'timeLimitCol', 'timeLimitDesc')) {
		return false;
	}
	
	// 付息周期
	var paymentCycleObj = document.getElementById("paymentCycle");
	if(!paymentCycleBlur(paymentCycleObj, 'paymentCycleCol', 'paymentCycleDesc')) {
		return false;
	}
	
	// 预期最高年化收益率
	var expectedProfitObj = document.getElementById("expectedProfit");
	if(!expectedProfitBlur(expectedProfitObj, 'expectedProfitCol', 'expectedProfitDesc')) {
		return false;
	}
	
	// 产品类型
	var productTypeObj = document.getElementById("productType");
	if(!productTypeBlur(productTypeObj, 'productTypeCol', 'productTypeDesc')) {
		return false;
	}
	
	// 委托起始金额
	var startAmountObj = document.getElementById("startAmount");
	if(!startAmountBlur(startAmountObj, 'startAmountCol', 'startAmountDesc')) {
		return false;
	}
	
	// 收益类型
	var earningsTypeObj = document.getElementById("earningsType");
	if(!earningsTypeBlur(earningsTypeObj, 'earningsTypeCol', 'earningsTypeDesc')) {
		return false;
	}
	
	// 发售地区
	var placeAreaObj = document.getElementById("placeArea");
	if(!placeAreaBlur(placeAreaObj, 'placeAreaCol', 'placeAreaDesc')) {
		return false;
	}
	
	// 递增单位
	var incrementByObj = document.getElementById("incrementBy");
	if(!incrementByBlur(incrementByObj, 'incrementByCol', 'incrementByDesc')) {
		return false;
	}
	
	// 产品管理费
	var feesObj = document.getElementById("fees");
	if(!feesBlur(feesObj, 'feesCol', 'feesDesc')) {
		return false;
	}
	
	// 提前终止条件
	var earlyTermCondObj = document.getElementById("earlyTermCond");
	if(!earlyTermCondBlur(earlyTermCondObj, 'earlyTermCondCol', 'earlyTermCondDesc')) {
		return false;
	}

	// 产品说明
	var productDescObj = document.getElementById("productDesc");
	if(!productDescBlur(productDescObj, 'productDescCol', 'productDescDesc')) {
		return false;
	}
	
	// 收益率说明
	var eariningsDescObj = document.getElementById("eariningsDesc");
	if(!eariningsDescBlur(eariningsDescObj, 'eariningsDescCol', 'eariningsDescDesc')) {
		return false;
	}
	
	document.getElementById("bankProductForm").submit();
    return true;
}

